package com.example.controlleradvice.community;

import com.example.controller.community.CommunityControllerMarker;
import com.example.controller.community.DynamicCommentController;
import com.example.controller.community.DynamicController;
import com.example.exception.community.DynamicNotExistException;
import com.example.response.ApiResult;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author LeXin Huang
 * @date 2021年04月25日 21:13
 */
@Order(0)
@RestControllerAdvice(basePackageClasses = {CommunityControllerMarker.class})
public class CommunityControllerAdvice {

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(value = DynamicNotExistException.class)
    public ApiResult<ApiResult.ApiData> handle1(DynamicNotExistException e) {
        return ApiResult.buildErrorResponse(e.getCode(), e.getMsg());
    }

}
